<template>
  <div>
    <div class="box">
      <div style="width: 24%">
        <el-card>
          <el-row>
            <el-col> 执行标准 </el-col>
          </el-row>
          <el-row>
            <el-col class="allBtn">
              <a-upload name="file" :action="uploadUrl1" accept=".xls,.xlsx" :data="paramData1" :multiple="true" @change="handleChange" :showUploadList="false"> <el-button type="primary" size="mini">文件上传</el-button> </a-upload>
              <el-button type="primary" size="small" @click="tempDownLoad('材料执行标准模板')" style="padding: 7px 15px;">模板下载</el-button>
            </el-col>
          </el-row>
        </el-card>
      </div>
      <div style="width: 24%;margin-left:10px;">
        <el-card>
          <el-row>
            <el-col> 测量标准 </el-col>
          </el-row>
          <el-row>
            <el-col class="allBtn">
              <a-upload name="file" :action="uploadUrl2" accept=".xls,.xlsx" :data="paramData" :multiple="true" @change="handleChange" :showUploadList="false"> <el-button type="primary" size="mini">文件上传</el-button> </a-upload>
              <el-button type="primary" size="small" @click="tempDownLoad('材料测试标准模板')" style="padding: 7px 15px;">模板下载</el-button>
            </el-col>
          </el-row>
        </el-card>
      </div>
      <div style="width: 24%;margin-left:10px;">
        <el-card>
          <el-row>
            <el-col> 生产商信息 </el-col>
          </el-row>
          <el-row>
            <el-col class="allBtn">
              <a-upload name="file" :action="uploadUrl3" accept=".xls,.xlsx" :data="paramData" :multiple="true" @change="handleChange" :showUploadList="false"> <el-button type="primary" size="mini">文件上传</el-button> </a-upload>
              <el-button type="primary" size="small" @click="tempDownLoad('材料制造商模板')" style="padding: 7px 15px;">模板下载</el-button>
            </el-col>
          </el-row>
        </el-card>
      </div>
      <div style="width: 24%;margin-left:10px;">
        <el-card>
          <el-row>
            <el-col> 化学成分 </el-col>
          </el-row>
          <el-row>
            <el-col class="allBtn">
              <a-upload name="file" :action="uploadUrl4" accept=".xls,.xlsx" :data="paramData" :multiple="true" @change="handleChange" :showUploadList="false"> <el-button type="primary" size="mini">文件上传</el-button> </a-upload>
              <el-button type="primary" size="small" @click="tempDownLoad('化学成分表模板')" style="padding: 7px 15px;">模板下载</el-button>
            </el-col>
          </el-row>
        </el-card>
      </div>
    </div>
    <div class="box">
      <div style="width: 24%;">
        <el-card>
          <el-row>
            <el-col> 材料标签 </el-col>
          </el-row>
          <el-row>
            <el-col class="allBtn">
              <a-upload name="file" :action="uploadUrl5" accept=".xls,.xlsx" :data="paramData" :multiple="true" @change="handleChange" :showUploadList="false"> <el-button type="primary" size="mini">文件上传</el-button> </a-upload>
              <el-button type="primary" size="small" @click="tempDownLoad('材料标签模板')" style="padding: 7px 15px;">模板下载</el-button>
            </el-col>
          </el-row>
        </el-card>
      </div>
      <div style="width: 24%;margin-left:10px;">
        <el-card>
          <el-row>
            <el-col> 材料制造商标签 </el-col>
          </el-row>
          <el-row>
            <el-col class="allBtn">
              <a-upload name="file" :action="uploadUrl6" accept=".xls,.xlsx" :data="paramData" :multiple="true" @change="handleChange" :showUploadList="false"> <el-button type="primary" size="mini">文件上传</el-button> </a-upload>
              <el-button type="primary" size="small" @click="tempDownLoad('材料制造商标签模板')" style="padding: 7px 15px;">模板下载</el-button>
            </el-col>
          </el-row>
        </el-card>
      </div>
      <div style="width: 24%;margin-left:10px;">
        <el-card>
          <el-row>
            <el-col> 牌号信息 </el-col>
          </el-row>
          <el-row>
            <el-col class="allBtn">
              <a-upload name="file" :action="uploadUrl7" accept=".xls,.xlsx" :data="paramData" :multiple="true" @change="handleChange" :showUploadList="false"> <el-button type="primary" size="mini">文件上传</el-button> </a-upload>
              <el-button type="primary" size="small" @click="tempDownLoad('相同相近牌号模板')" style="padding: 7px 15px;">模板下载</el-button>
            </el-col>
          </el-row>
        </el-card>
      </div>
      <div style="width: 24%;margin-left:10px;">
        <el-card>
          <el-row>
            <el-col> 仪表仪器标签 </el-col>
          </el-row>
          <el-row>
            <el-col class="allBtn">
              <a-upload name="file" :action="uploadUrl8" accept=".xls,.xlsx" :data="paramData" :multiple="true" @change="handleChange" :showUploadList="false"> <el-button type="primary" size="mini">文件上传</el-button> </a-upload>
              <el-button type="primary" size="small" @click="tempDownLoad('测试仪器信息模板')" style="padding: 7px 15px;">模板下载</el-button>
            </el-col>
          </el-row>
        </el-card>
      </div>
    </div>
    <div class="box">
      <div style="width: 24%;">
        <el-card>
          <el-row>
            <el-col> 供应商信息 </el-col>
          </el-row>
          <el-row>
            <el-col class="allBtn">
              <a-upload name="file" :action="uploadUrl9" accept=".xls,.xlsx" :data="paramData" :multiple="true" @change="handleChange" :showUploadList="false"> <el-button type="primary" size="mini">文件上传</el-button> </a-upload>
              <el-button type="primary" size="small" @click="tempDownLoad('供应商信息模板')" style="padding: 7px 15px;">模板下载</el-button>
            </el-col>
          </el-row>
        </el-card>
      </div>
      <div style="width: 24%;margin-left:10px;">
        <el-card>
          <el-row>
            <el-col> 模板上传 </el-col>
          </el-row>
          <el-row>
            <el-col class="allBtn">
              <a-upload name="file" :action="uploadUrl10" accept=".xls,.xlsx,.docx,.doc" :data="paramData" :multiple="true" @change="handleChange" :showUploadList="false"> <el-button type="primary" size="mini">文件上传</el-button> </a-upload>
            </el-col>
          </el-row>
        </el-card>
      </div>
    </div>
    <!-- <div class="box">
      <div style="width: 24%">
        <el-card>
          <el-row>
            <el-col> 数据上传 </el-col>
          </el-row>
          <el-row>
            <el-col>
              <a-upload name="file" :action="uploadUrl9" accept=".xls,.xlsx,.docx,.doc,.zip" :multiple="true" @change="handleChange" :showUploadList="false"> <el-button type="primary" size="mini">文件上传</el-button> </a-upload>
            </el-col>
          </el-row>
        </el-card>
      </div>
    </div> -->
  </div>
</template>

<script>
import { Message } from 'element-ui'
export default {
  data() {
    return {
      paramData1: {
        name: 'file',
      },
      paramData: {
        name: 'file',
        userId: JSON.parse(localStorage.getItem('pro__Login_Userinfo')).value.id,
      },
      uploadUrl1: 'http://59.172.104.174:31770/basicsExecutionStandard/importExcelByAdmin', //执行标准
      uploadUrl2: 'http://59.172.104.174:31770/basicsMeasurementStandard/importExcelByAdmin', //测量标准
      uploadUrl3: 'http://59.172.104.174:31770/basicsProducerInformation/importExcelByAdmin', //生产商信息
      uploadUrl4: 'http://59.172.104.174:31770/basicsChemicalComponent/importExcelByAdmin', //化学成分
      uploadUrl5: 'http://59.172.104.174:31770/basicsMaterialLabel/importExcelByAdmin', //材料标签
      uploadUrl6: 'http://59.172.104.174:31770/basicsManufacturerLabel/importExcelByAdmin', //材料制造商标签
      uploadUrl7: 'http://59.172.104.174:31770/basicsMarks/importExcelByAdmin', //牌号信息
      uploadUrl8: 'http://59.172.104.174:31770/basics-test-instrument/importExcelByAdmin', //仪表仪器
      uploadUrl9: 'http://59.172.104.174:31770/basicsSupplierInformation/importExcelByAdmin', //供应商信息
      uploadUrl10: 'http://59.172.104.174:30669/admin/uploadLessonFile', //模板上传
      // uploadUrl9: 'http://59.172.104.174:30669/admin/uploadZip' //数据上传
    }
  },
  created() {},
  methods: {
    handleChange(info) {
      if (info.file.status === 'done') {
        if (info.file.response.code == '201') {
          this.$message.success('重新上传文件成功！')
        } else if (info.file.response.code == '200') {
          this.$message.success('上传文件成功！')
        }
      }
    },
    tempDownLoad(downLoadFileName) {
      this.axios({
        baseURL: 'http://59.172.104.174:30669',
        url: `/admin/downLoadLessonFile?name=${downLoadFileName}`,
        methods: 'GET',
        responseType: 'blob'
      }).then(res => {
        const blob = new Blob([res.data])
        const url = window.URL.createObjectURL(blob)
        const link = document.createElement('a')
        link.style.display = 'none'
        link.download = `${downLoadFileName}.xlsx`
        link.href = url
        link.click()
      })
    }
  }
}
</script>

<style scoped>
.box {
  margin-top: 10px;
  display: flex;
  /* justify-content: space-between; */
}
.allBtn {
  display: flex;
  justify-content: space-between;
}
</style>
